
# Miners Library Description

## Introduction

The miners library is used to compute xoron genesis bases.

## Definitions

Library header.

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
#ifndef XRN_MINERS_LIB_H
#define XRN_MINERS_LIB_H
```

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
#include "xrn_settings.h"
#include "xrn_common.h"
#include "xrn_arithmetic.h"
#include "xrn_arithmetic_backend.h"
#include "xrn_core.h"
#include "xrn_core_backend.h"
#include "xrn_encoder.h"
```

## Functions

## Enumerations definition

### xrn_mine_stocastic_wrapper

**Description:**

The **xrn_mine_stocastic_wrapper** is used to set all the default log stream.

**Function declaration:**

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
int xrn_mine_stocastic_wrapper ( 
    FILE * genesis_base_fpw,
    int maxn,
    int minn,
    unsigned max_try,
    uint8_t pseudo_rnd_mining_en,
    FILE * seed_fp,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **output:** genesis_base_fpw     $\rightarrow$ The genesis base file pointer. \
> **input:** maxn                 $\rightarrow$ The maximum number of '1' per raw. \
> **input:** minn                 $\rightarrow$ The minimum number of '1' per raw. \
> **input:** max_try              $\rightarrow$ The maximum number of tries. \
> **input:** pseudo_rnd_mining_en $\rightarrow$ The randomness mode (0-> true randomness), (1-> pseudo randomness) \
> **input:** seed_fp              $\rightarrow$ The seed file pointer. It is used if pseudo_rnd_mining_en = 1. \
> **inout:** settings         $\rightarrow$ The run time settings.

[comment]: <> ( docautocomplete xrn_mine_stocastic_wrapper  )

### xrn_mine_stocastic

**Description:**

The **xrn_mine_stocastic** is used mine a xoron genesis base with the one third algorithm.
The algorithm uses heuristics to determine the xoron genesis base.

**Function declaration:**

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
int xrn_mine_stocastic (
    unsigned seed,
    xgenesis_base_t * genesis_base,
    int maxn,
    int minn
);
```

**Arguments description:**

> **input:** seed         $\rightarrow$ The seed for the pseudo random number number to propose genesis bases. \
> **output:** genesis_base $\rightarrow$ The genesis base pointer. \
> **input:** maxn         $\rightarrow$ The maximum number of '1' per raw. \
> **input:** minn         $\rightarrow$ The minimum number of '1' per raw. 

[comment]: <> ( docautocomplete xrn_mine_stocastic  )

### xrn_mine_random_wrapper

**Description:**

The **xrn_mine_random_wrapper** is used mine a xoron genesis base with a purely random algorithm.

**Function declaration:**

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
int xrn_mine_random_wrapper ( 
    FILE * genesis_base_fpw,
    float probability,
    unsigned max_try,
    uint8_t pseudo_rnd_mining_en,
    FILE * seed_fp,
    xrn_crypto_extra_settings_t settings
);
```

**Arguments description:**

> **output:** genesis_base_fpw     $\rightarrow$ The genesis base file pointer. \
> **input:** probability          $\rightarrow$ The probability of assigning a bit of the genesis base with a '1' \
> **input:** max_try              $\rightarrow$ The maximum number of tries. \
> **input:** pseudo_rnd_mining_en $\rightarrow$ The randomness mode (0-> true randomness), (1-> pseudo randomness) \
> **input:** seed_fp              $\rightarrow$ The seed file pointer. \
> **inout:** settings         $\rightarrow$ The run time settings.

[comment]: <> ( docautocomplete xrn_mine_random_wrapper  )

### xrn_mine_random

**Description:**

The **xrn_mine_random** is used mine a xoron genesis base with a purely random algorithm.

**Function declaration:**

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
int xrn_mine_random ( 
    unsigned seed, 
    xgenesis_base_t * genesis_base,
    float probability
);
```

**Arguments description:**

> **input:** seed         $\rightarrow$ The seed for the pseudo random number number to propose genesis bases. \
> **output:** genesis_base $\rightarrow$ The genesis base pointer. \
> **input:** probability  $\rightarrow$ The probability of assigning a bit of the genesis base with a '1' 

[comment]: <> ( docautocomplete xrn_mine_random )

### xrn_check_set_stocastic_settings

**Description:**

The **xrn_check_set_stocastic_settings** is used to set mininig settings, or to check if settings are within limits.

**Function declaration:**

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
int xrn_check_set_stocastic_settings ( 
    int *maxn,
    int *minn,
    XBIT_TYPE check
);
```

**Arguments description:**

> **inout:**  maxn  $\rightarrow$ The maximum number of '1' per raw to set/check. \
> **inout:**  minn  $\rightarrow$ The minimum number of '1' per raw to set/check. \
> **input:** check $\rightarrow$ If check = 1, the function checks if the provided probability is within the limit. If check = 0, the function sets the default probability. 

[comment]: <> ( docautocomplete xrn_check_set_stocastic_settings )

### xrn_mine_random_settings

**Description:**

The **xrn_mine_random_settings** is used to set mininig settings, or to check if settings are within limits.

**Function declaration:**

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
int xrn_mine_random_settings ( 
    float *probability,
    XBIT_TYPE check
);
```

**Arguments description:**

> **inout:**  probability  $\rightarrow$ The probability to set/check. \
> **input:** check        $\rightarrow$ If check = 1, the function checks if the provided probability is within the limit. If check = 0, the function sets the default probability. 

[comment]: <> ( docautocomplete xrn_mine_random_settings  )

## End of the library

[comment]: <> (../inc/xrn_miners.h)
```Xoronos_C
#endif
```

